/**\file gr_streamdata.cpp Streamdata.
*
*/
#include "gr_streamdata.h"


#include <vector>
#include <memory>
#include <functional>
#include <cassert>

namespace gr {


StreamData::StreamData(){}

//void setSignature(StreamChannelInfo* signature, int count, size_t vertexSize, std::function<uint32_t(size_t)> getLocationFromOffset) override
void StreamData::setSignature(StreamSignature& signature)
{
    signature_ = signature;
}

void StreamData::setData(uint8_t* buffer, size_t size)
{
    data_.assign(buffer, buffer + size);
}

void StreamData::free()
{
    data_.clear();
}

size_t StreamData::size()
{
    return data_.size();
}

size_t StreamData::sampleSize()
{
    return signature_.sampleSize();
}

size_t StreamData::sampleStride()
{
    return signature_.sampleSize();
}


uint8_t* StreamData::data()
{
    return &data_[0];
}
StreamSignature& StreamData::signature()
{
    return signature_;
}

/* StreamGeometryIndexData */

StreamGeometryIndexData::StreamGeometryIndexData():layout_(TRIANGLES)
{}

void StreamGeometryIndexData::setData(uint16_t* indices,size_t count )
{
    indices_.assign(indices, indices + count);
}

size_t StreamGeometryIndexData::indexCount()
{
    return indices_.size();
}

GeometryIndexLayout StreamGeometryIndexData::layout()
{
    return layout_;
}

void StreamGeometryIndexData::layout(GeometryIndexLayout l)
{
    layout_ = l;
}

uint16_t* StreamGeometryIndexData::data()
{
    return &indices_[0];
}

size_t StreamGeometryIndexData::size()
{
    return indices_.size();
}

void StreamGeometryIndexData::free()
{
    indices_.clear();
}


StreamData* newStreamData()
{
    return new StreamData();
}

StreamGeometryIndexData* newStreamGeometryIndexData()
{
    return new StreamGeometryIndexData();
}



}
